﻿<%@ Page Language="C#" MasterPageFile="~/Site.master"    
    CodeFile="QueryableFilterRepeater.aspx.cs" 
    Inherits="QueryableFilterRepeaterSample" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>

<asp:Content ID="headContent" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

   
    <h2 class="DDSubHeader">Fitering <%= table.DisplayName%> Table Rows Using Supported Foreign-keys</h2>

    <div class="ExampleView">
	 Dynamic Data creates the UI to filter table rows by using the default 
     filter templates that are in the ~\DynamicData\Filters folder. <br />
     The default templates support foreign-key, Boolean, and enumeration column types. <br />
	 The example uses the 
     <a href="http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.queryablefilterrepeater(VS.100).aspx" target="_blank"> 
	 <code>System.Web.DynamicData.QueryableFilterRepeater</code></a> control to create the UI for filtering 
     rows by using the foreign-keys <i>Product</i> and <i>SalesOrderHeader</i>.
	 <br />
	 </div>
     
    <hr />
   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="Vui lòng sửa lại các lỗi dưới đây" />
            <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />
            
            <!-- Set the QueryableFilterRepeater control attributes. --> 
          <asp:QueryableFilterRepeater runat="server" ID="FilterRepeaterID">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' />
                    <asp:DynamicFilter runat="server" ID="DynamicFilter" 
                        OnFilterChanged="OnFilterSelectionChanged"  /><br />
                </ItemTemplate>
            </asp:QueryableFilterRepeater>
           
           
           
                   
            <br />

             <!-- Data-bound control that shows the filtered table rows. -->
            <asp:GridView ID="GridView1" runat="server" 
                DataSourceID="GridDataSource" EnablePersistedSelection="true"
                AllowPaging="True" AllowSorting="True" CssClass="DDGridView">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="DeleteLinkButton" runat="server" CommandName="Delete"
                                CausesValidation="true" Text="Delete"
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'
                            />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

                <PagerStyle CssClass="footer"/>        
                <PagerTemplate>
                    <asp:GridViewPager ID="GridViewPager1" runat="server" />
                </PagerTemplate>
                <EmptyDataTemplate>
                    Chưa có dữ liệu.
                </EmptyDataTemplate>
            </asp:GridView>
           
            <asp:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="True" 
                ContextTypeName="AdventureWorksLT_DataModel.AdventureWorksLT_DataEntities" 
                EnableFlattening="False" 
                EntitySetName="SalesOrderDetails"  />
        
            
            <!-- The control that handles the details for querying 
            the database, after a user's filtering action -->
            <asp:QueryExtender ID="QueryBlock1"  
                TargetControlID="GridDataSource" runat="server">
                <asp:DynamicFilterExpression ControlID="FilterRepeaterID" />
                
            </asp:QueryExtender>
        </ContentTemplate>
    </asp:UpdatePanel>


</asp:Content>
